<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Tasks</title>

    </h:head>
     <f:view beforePhase="#{UserDisplayManagedBean.doDisplay}">
    <f:view beforePhase="#{TaskManagedBean.initView}">
    <h:body>      
       
        <h:form prependId="false">
            <p:growl id="msgs" showDetail="true"/>
        
            <div id="top" class="top" style="margin-top:0%; margin-bottom:0%">
                <h:graphicImage value="/image/newHeader.jpg"/>
                 <p:ajaxStatus style="width:16px;height:16px;">
                                        <f:facet name="start">
                                            <h:graphicImage value="25(2).gif" />
                                        </f:facet>
                                        <f:facet name="complete">
                                            <h:outputText value="" />
                                        </f:facet>
                                    </p:ajaxStatus>
              <!-- <hr size="5" style="width:100%;color: lavender;background-color: lavender;margin-top:0%;margin-bottom:0%;border-style:none" noshade="blue"/      -->
            </div>
             <div id="content">
                        <table>
                            <tr>
                                <td style="vertical-align:top">
                                    <p:toolbar style="font-size:80%;height:33px;width:207px"> 
                                        <p:toolbarGroup align="right">
                                            <p:button title="Home" image="ui-icon-home" outcome="ManufacturingDeptWorkspace"/>
                                            <p:button title="Notes" image="ui-icon-note" outcome="tasks"/>
                                            <p:button title="Mail" outcome="messages" image="ui-icon-mail-closed"/>     
                                            <p:button title="Edit Preferences" image="ui-icon-gear"/>
                                            <p:button title="Help" image="ui-icon-help"/>
                                            <p:commandButton immediate="true" type="submit" image="ui-icon-close" actionListener="#{UserManagedBean.doLogout}"/> 
                                        </p:toolbarGroup>
                                    </p:toolbar>

                                     <p:menu id="menu" style=" width:205px;height: 855px;font-family: Verdana;border-style: double;font-size: 80%">  
                                    <p:submenu label="Manufacturing Menu">  
                                        <p:menuitem value="Manufacturing Dept Home" url="http://localhost:8080/MerlionERP-war/MRP/ManufacturingDeptWorkspace.xhtml" ajax="false" icon="ui-icon ui-icon-home"/>  
                                    </p:submenu>
                                    <p:submenu label="Production Planning">
                                        <p:menuitem value="View Sales Record" url="http://localhost:8080/MerlionERP-war/MRP/SalesRecord.xhtml" ajax="false" icon="ui-icon ui-icon-search"/>  
                                        <p:menuitem value="View Sales Forecast" url="http://localhost:8080/MerlionERP-war/MRP/SalesForecast.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        <p:menuitem value="View Sales and Operation Plan" url="http://localhost:8080/MerlionERP-war/MRP/SalesAndOperationPlan.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                    </p:submenu>
                                    <p:submenu label="Master Production Schedule">
                                        <p:menuitem value="View MPS Weekly" url="http://localhost:8080/MerlionERP-war/MRP/MasterProductionScheduleWeekly.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        <p:menuitem value="View MPS Daily" url="http://localhost:8080/MerlionERP-war/MRP/MasterProductionScheduleDaily.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                        <p:menuitem value="Commit MPS" url="http://localhost:8080/MerlionERP-war/MRP/CommitMasterProductionSchedule.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                    </p:submenu>
                                    <p:submenu label="Material Planning">
                                        <p:menuitem value="View Requirement Planning" url="http://localhost:8080/MerlionERP-war/MRP/MaterialRequirementPlanning.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                    </p:submenu>
                                    <p:submenu label="Bill of Materials">
                                        <p:menuitem value="View Bill of Materials" url="http://localhost:8080/MerlionERP-war/MRP/BillOfMaterials.xhtml" ajax="false" icon="ui-icon ui-icon-search" />
                                    </p:submenu>
                                </p:menu>

                                <p:calendar mode="inline" style="font-size:11px;font-family:Tahoma"/>
                            </td>
                      
                        <td style="vertical-align:top">
                           
                            <h:graphicImage value="task-report-hot.png" style="width:40px;height:40px" />
                            <h:outputText value="         "/>
                            <h:outputText value="Tasks" style="font-family:Tahoma;font-size:20px;font-weight:bolder"/>
                            <p:spacer width="100" height="10"/>
                    
                        <p:toolbar style="font-size: 11px;width: 99.5%"> 
                                <p:toolbarGroup align="left">  
                                    <p:commandButton value="New Task" update="display1" oncomplete="addTaskDialog.show()"
                                                     image="ui-icon ui-icon-plus"/>
                                  <!--  <p:commandButton title="Delete" image="ui-icon ui-icon-trash"
                                                     value="Delete" oncomplete="deleteDialog.show()"  />-->
               
                                </p:toolbarGroup>  

                            </p:toolbar> 
           
                           <p:dataTable id="taskTable" value="#{TaskManagedBean.taskList}"
                                        var="task" paginator="true" rows="10"
                                        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                       
                                        rowsPerPageTemplate="10,15,20" style="font-family:Tahoma;font-size:11px;width:100%"                      
                                        emptyMessage="No data found with given criteria" widgetVar="taskTable"> 
    
                              
                                <f:facet name="header">                           
                                    <p:outputPanel style="text-align:right"  >
                                        <h:outputText value="Search all fields:"/>  
                                        <p:inputText id="globalFilter" onkeyup="taskTable.filter()" style="right:-100px;width:150px" />  
                                    </p:outputPanel>                                
                                </f:facet>

                                <p:column headerText="Del." style="width: 20px;border-left-color:transparent"> <!--border-right-color:transparent"-->
                                    <!--DELETE-->
                                    <p:commandButton title="Delete" image="ui-icon ui-icon-trash" ajax="true" immediate="true"
                                                     update="taskTable" oncomplete="deleteDialog.show()">
                                        <f:setPropertyActionListener target="#{TaskManagedBean.selectedTask}"
                                                                     value="#{task}"/>
                                    </p:commandButton>

                                </p:column>  

                                <p:column headerText= "Title" sortBy="#{task.title}" filterBy="#{task.title}" 
                                          filterStyle="width:60px" filterMatchMode="contains" >
                                          <!--style="border-left-color:transparent;border-right-color:transparent"-->                                   
                                            <h:outputText value="#{task.title}" />            
                                </p:column>  

                                   
                                <p:column headerText="Date Created" sortBy="#{task.dateCreated}" filterBy="#{task.dateCreated}" filterMatchMode="contains" 
                                          filterStyle="width:60px" >
                                          <!--style="border-left-color:transparent;border-right-color:transparent"-->  

                                            <h:outputText value="#{task.dateCreated}" />  

                                </p:column>  

   
                                <p:column headerText="Date Due" sortBy="#{task.dateDue}" filterBy="#{task.dateDue}" 
                                          filterStyle="width:60px" filterMatchMode="contains" >
                                          <!--style="border-left-color:transparent;border-right-color:transparent"-->  
                                        <h:outputText value="#{task.dateDue}" />  
  
                                </p:column>  
                               <p:column headerText="Status">
                                   <h:outputText value="Expired" rendered="#{task.expired}"/>
                                   <h:outputText value="Valid" rendered="#{!task.expired}"/>
                               </p:column>
                               
                               <p:column style="width:40px">  
                                    <p:commandLink update="display2" oncomplete="editDialog.show()" title="Edit Details">
                                        <p:graphicImage value="about_icon.png" style="width:20px;height:20px"/>
                                        <f:setPropertyActionListener value="#{task}" target="#{TaskManagedBean.selectedViewTask}" />  
                                        <f:setPropertyActionListener value="#{true}" target="#{TaskManagedBean.editMode}" />  
                                    </p:commandLink>                                                                
                                </p:column>

                           </p:dataTable>
                            
                        </td></tr></table>
                           
                           <p:dialog  widgetVar="addTaskDialog" width="800" modal="true">
                               <p:panel header="Add New Task">
                                   <h:panelGrid id="display1" columns="3" style="font-family:Tahoma;font-size:11px">

                                       <h:outputText value="Task Name"/>
                                       <h:outputText value=":"/>
                                       <p:inputText value="#{TaskManagedBean.title}"/>
                                       
                                       <h:outputText value="Date Due"/>
                                       <h:outputText value=":"/>
                                       <p:calendar value="#{TaskManagedBean.dateDue}" pattern="dd/MM/yyyy" />
                                   
                                      
                                        
                                        <h:outputLabel for="minute" value="Minutes"/>
                                         <p:spinner id="minute"  
                                            value="#{TaskManagedBean.m}" min="0" max="59"/> 
                                        <h:outputText value=""/>
                                         
                                        <h:outputLabel for="hour" value="Hour"/>
                                        <p:spinner id="hour" value="#{TaskManagedBean.h}" min="0" max="23"/>
                                        <h:outputText value=""/>
                                        
                                        <h:outputText value="Set Reminder"/>
                                        <h:selectOneRadio  value="#{TaskManagedBean.reminder}" >
                                                    <f:selectItem itemValue="Y" itemLabel="Yes"/>   
                                                    <f:selectItem itemValue="N" itemLabel="No"/>
                                                </h:selectOneRadio>
                                        <h:outputText value=""/>
                                        
                                        <h:outputText value="Select Reminder Time"/>
                                        <h:selectOneMenu value="#{TaskManagedBean.rTime}" >
                                            <f:selectItem itemLabel="5" itemValue="5" />
                                            <f:selectItem itemLabel="10" itemValue="10"/>
                                            <f:selectItem itemLabel="15" itemValue="15"/>
                                            <f:selectItem itemLabel="30" itemValue="30"/>
                                            <f:selectItem itemLabel="60" itemValue="60"/>
                                        </h:selectOneMenu>
                                        <h:outputText value=""/>

                                        <h:outputText value="Description"/>
                                        <h:outputText value=":"/>
                                        <p:inputTextarea value="#{TaskManagedBean.task}" style="width:200px;height:100px"/>
                                        
                                     
                                      
                                    </h:panelGrid>  

                                         <p:commandButton  value="Add" update="taskTable"  
                                                          actionListener="#{TaskManagedBean.addTask}"
                                                          oncomplete="addTaskDialog.hide()" style="margin-left:200px" image="ui-icon ui-icon-plus" >  
                                           
                                         </p:commandButton>  
                                         <p:commandButton value="Reset" type="reset" image="ui-icon ui-icon-arrowrefresh-1-s"/>  
                               </p:panel>
                           </p:dialog>
                
                   <p:dialog header="Task Detail" widgetVar="editDialog" resizable="true"  
                                  modal="true" width="800" showEffect="blind" hideEffect="blind">  
                            <center>
                                <h:panelGrid id="display2" columns="3" cellpadding="4" style="font-family:Tahoma; font-size:12px">  


                                    <h:outputText value="Task Id" />  
                                    <h:outputText value=":"/>
                                    <h:outputText value="#{TaskManagedBean.selectedViewTask.id}" />  

                                    <h:outputText value="Date Created" />  
                                    <h:outputText value=":"/>
                                    <h:outputText value="#{TaskManagedBean.selectedViewTask.dateCreated}" />  



                                    <h:outputText value="Title" /> 
                                    <h:outputText value=":"/>
                                    <h:panelGroup>  
                                        <h:outputText value="#{TaskManagedBean.selectedViewTask.title}" style="font-weight:bold" rendered="#{!TaskManagedBean.editMode}"/>  
                                        <p:inputText value="#{TaskManagedBean.selectedViewTask.title}" rendered="#{TaskManagedBean.editMode}" required="true" label="Title"/>  
                                    </h:panelGroup> 


                                   <h:outputText value="Date Due" style="font-weight:bold"/>
                                    <h:outputText value=":"/>
                                   <h:panelGroup>
                                        <h:outputText value="#{TaskManagedBean.selectedViewTask.dateDue}"
                                                      style="font-weight:bold" rendered="#{!TaskManagedBean.editMode}"/>
                                        <p:calendar value="#{TaskManagedBean.selectedViewTask.dateDue}"
                                                    rendered="#{TaskManagedBean.editMode}" required="true"/>
                                    </h:panelGroup>


                                    <h:outputText value="Hour" />
                                    <h:outputText value=":"/>
                                    <h:panelGroup>
                                        <h:outputText value="#{TaskManagedBean.selectedViewTask.hourDue}" style="font-weight:bold" rendered="#{!TaskManagedBean.editMode}" />  
                                        <p:inputText value="#{TaskManagedBean.selectedViewTask.hourDue}" rendered="#{TaskManagedBean.editMode}" required="true" label="Hour Due"/>
                                    </h:panelGroup> 


                                    <h:outputText value="Minute Due" />
                                    <h:outputText value=":"/>
                                    <h:panelGroup>
                                        <h:outputText value="#{TaskManagedBean.selectedViewTask.minuteDue}" style="font-weight:bold" rendered="#{!TaskManagedBean.editMode}" />  
                                        <p:inputText value="#{TaskManagedBean.selectedViewTask.minuteDue}" rendered="#{TaskManagedBean.editMode}" required="true" label="Minute Due"/>
                                    </h:panelGroup> 


                                          <h:outputText value="Reminder Time" />
                               <h:outputText value=":"/>
                               <h:panelGroup>  
                                   <h:outputText value="#{TaskManagedBean.selectedViewTask.reminderTime}" style="font-weight:bold" rendered="#{!TaskManagedBean.editMode}"/>  
                                   <h:selectOneMenu value="#{TaskManagedBean.selectedViewTask.reminderTime}" rendered="#{TaskManagedBean.editMode}">  
                                       <f:selectItem itemLabel="5" itemValue="5" />  
                                       <f:selectItem itemLabel="10" itemValue="10"/>
                                        <f:selectItem itemLabel="15" itemValue="15" />  
                                        <f:selectItem itemLabel="30" itemValue="30"/>
                                        <f:selectItem itemLabel="60" itemValue="30"/>             
                                   </h:selectOneMenu>  
                               </h:panelGroup>  
          

                                    <h:outputText value="Description" />
                                    <h:outputText value=":"/>
                                    <h:panelGroup>  
                                        <h:outputText value="#{TaskManagedBean.selectedViewTask.task}" style="font-weight:bold" rendered="#{!TaskManagedBean.editMode}"/>  
                                        <p:inputText value="#{TaskManagedBean.selectedViewTask.task}" rendered="#{TaskManagedBean.editMode}" required="true" label="Description"/>  
                                    </h:panelGroup>  

      
                                    <p:outputPanel rendered="#{TaskManagedBean.editMode}" layout="block" style="text-align:right">  
                                        <p:commandButton value="Save" update="panel" actionListener="#{TaskManagedBean.save}"   
                                                         oncomplete="editDialog.hide()" image="ui-icon ui-icon-check" />  
                                        <p:commandButton value="Cancel" onclick="editDialog.hide()" type="button" image="ui-icon ui-icon-close"/>  
                                    </p:outputPanel>  


                                </h:panelGrid>  
                            </center>
                        </p:dialog>  
                               
                <p:dialog widgetVar="deleteDialog" modal="true" width="500">
                    <h:panelGrid columns="1">
                    <h:outputText value="Are you sure you want to delete this task?"/>
                       <p:commandButton  value="Delete" update="taskTable" ajax="true" immediate="true"
                                         actionListener="#{TaskManagedBean.deleteTask}" oncomplete="deleteDialog.hide()"
                                                          style="margin-left:200px" image="ui-icon ui-icon-trash" >  
                                           
                                         </p:commandButton>  
                    <p:commandButton value="Cancel" onclick="deleteDialog.hide()" />  
                    </h:panelGrid>

                </p:dialog>
            </div>
            <div id="bottom" class="bottom">
                <h:graphicImage value="/image/merlionfooter.jpg"/>
            </div>
        </h:form>
    </h:body>
    </f:view>
         </f:view>
</html>